package hgin

import "github.com/gin-gonic/gin"

func GET(g *gin.RouterGroup, path string, f func(ctx *gin.Context) error) {
	g.GET(path, fe(f))
}

func POST(g *gin.RouterGroup, path string, f func(ctx *gin.Context) error) {
	g.POST(path, fe(f))
}

func fe(f func(ctx *gin.Context) error) func(ctx *gin.Context) {
	return func(ctx *gin.Context) {
		err := f(ctx)
		if err != nil {
			_ = ctx.Error(err)
			ctx.Abort()
		}
	}
}
